
loop_time = 0.01
last_clicked = ''
new_site_location = '/on_rates'

function go_to_another_site(){
	window.location.href = new_site_location
}


function move_images(new_location){
    setTimeout(loop, 1000 * loop_time);
	new_site_location = new_location
    setTimeout(go_to_another_site, 800);
}


function hover_services(id){
	if(last_clicked == id){
		if(document.getElementById('drop_down_menu_id').style.display != 'none'){
			document.getElementById('drop_down_menu_id').style.display = 'none'
			return
		}
	}

	set_text_font_weight('on_services', '20px', '')
	set_text_font_weight('on_appoint', '20px', '')
	set_text_font_weight('on_pract', '20px', '')
	//set_text_font_weight('on_testi', '20px', '')
	set_text_font_weight('on_faq_id', '20px', '')
	set_text_font_weight('on_resources_id', '20px', '')

	set_text_font_weight(id, '22px', 'bold')

	


	if(id == 'on_services'){
		loc = screen.width/2 - 500
		content = '<div id=drop_down_menu_box_id class=drop_down_menu style="width:400px;margin-left:' + loc + 'px;">'
		content += div_link(20, 'javascript:move_images(\'/acupuncture\')', 'Acupuncture')
		content += div_link(20, 'javascript:move_images(\'/on_herbal\')', 'Herbal Medicine')
		content += div_link(20, 'javascript:move_images(\'/on_specialties\')', 'Our Specialties')
	}
	if(id == 'on_appoint'){
		loc = screen.width/2 - 300
		content = '<div id=drop_down_menu_box_id class=drop_down_menu style="width:280px;margin-left:' + loc + 'px;">'
		content += div_link(20, 'javascript:move_images(\'/on_rates\')', 'Rates')
		content += div_link(20, 'javascript:move_images(\'/on_appointment\')', 'Schedule an Appointment')
	}
	if(id == 'on_pract'){
		loc = screen.width/2 - 100
		content = '<div id=drop_down_menu_box_id class=drop_down_menu style="width:210px;margin-left:' + loc + 'px;">'
		content += div_link(20, 'javascript:move_images(\'/on_kathia\')', 'Kathia Wu')
		content += div_link(20, 'javascript:move_images(\'/on_jesse\')', 'Jesse Erwin')
	}
	if(id == 'on_testi'){
		loc = screen.width/2 + 100
		content = '<div id=drop_down_menu_box_id class=drop_down_menu style="width:350px;margin-left:' + loc + 'px;">'
		content += div_link(30, '#', 'For Acupuncture')
		content += div_link(30, '#', 'For Herbal Medicine')
	}

	if(id == 'on_faq_id'){
		loc = screen.width/2  - 50
		content = '<div id=drop_down_menu_box_id class=drop_down_menu style="width:400px;margin-left:' + loc + 'px;">'
		content += div_link(30, 'javascript:move_images(\'/on_credentials\')', 'On Credentials')
		content += div_link(30, 'javascript:move_images(\'/on_expectations\')', 'On Expectations')
		content += div_link(30, 'javascript:move_images(\'/on_whatis\')', 'What is?')
	}

	if(id == 'on_resources_id'){
		loc = screen.width/2  + 50 
		content = '<div id=drop_down_menu_box_id class=drop_down_menu style="width:400px;margin-left:' + loc + 'px;">'
		content += div_link(30, '#', 'Affiliated Practices')
		content += div_link(30, 'javascript:move_images(\'/on_resources\')', 'Supplementary Materials')
	}

	content += '</div>'
	document.getElementById('drop_down_menu_id').innerHTML = content
	document.getElementById('drop_down_menu_id').style.display = 'block'
	last_clicked = id
}

function link_mold(link, id, callback_id, title){

	content = '<a href="javascript:' + link + '" class=link_style>'
	content += '<span id=' + id + ' '
	content += 'onmouseover="javascript:hover_services(\'' + callback_id + '\');">'
	content += title + ' </span></a>'
	return content
}

function generate_links(type){

//Services Appointments Practitioner Testimonials FAQ

	content = link_mold('hover_services(\'on_services\')', 'on_services', 'on_services', 'Services')
	content += link_mold('hover_services(\'on_appoint\')', 'on_appoint', 'on_appoint', 'Appointments')
	content += link_mold('hover_services(\'on_pract\')', 'on_pract', 'on_pract', 'Practitioners')
	//content += link_mold('hover_services(\'on_testi\')', 'on_testi', 'on_testi', 'Testimonials')
	content += link_mold('hover_services(\'on_faq_id\')', 'on_faq_id', 'on_faq_id', 'FAQ')
	content += link_mold('hover_services(\'on_resources_id\')', 'on_resources_id', 'on_resources_id', 'Resources')


//	if(type == 'Acupuncture'){
//		content = '<a href="/acupuncture" class=link_style_bold >Acupuncture</a>'
//	}else{
//		content = '<a href="/acupuncture" class=link_style >Acupuncture</a>'
//	}
//
//	if(type == 'Herbal Medicine'){
//		content += '<a href="/on_herbal" class=link_style_bold >Herbal Medicine</a>'
//	}else{
//		content += '<a href="/on_herbal" class=link_style >Herbal Medicine</a>'
//	}
//
//	if(type == 'Rates'){
//		content += '<a href="/on_rates" class=link_style_bold >Rates</a>'
//	}else{
//		content += '<a href="/on_rates" class=link_style >Rates</a>'
//	}
//
//	if(type == 'The Practitioner'){
//		content += '<a href="/on_kathia" class=link_style_bold>The Practitioner</a>'
//	}else{
//		content += '<a href="/on_kathia" class=link_style>The Practitioner</a>'
//	}
//
//	if(type == 'Appointments'){
//		content += '<a href="/on_appointment" class=link_style_bold>Appointments</a>'
//	}else{
//		content += '<a href="/on_appointment" class=link_style>Appointments</a>'
//	}
//
//	if(type == 'FAQ'){
//		content += '<a href="/on_FAQ" class=link_style_bold >FAQ</a>'
//	}else{
//		content += '<a href="/on_FAQ" class=link_style>FAQ</a>'
//	}

	document.getElementById('base_link_id').innerHTML = content
}

function generate_links_manager(type){

	new_site_location = '/on_schedule' + document.location.search
	if(type == 'on_schedule'){
		content = '<a href="' + new_site_location + '" class=link_style_bold >Schedule</a>'
	}else{
		content = '<a href="' + new_site_location + '" class=link_style >Schedule</a>'
	}

	new_site_location = '/on_operation_hour' + document.location.search
	if(type == 'on_operation_hour'){
		content += '<a href="' + new_site_location + '" class=link_style_bold >Operation Hours</a>'
	}else{
		content += '<a href="' + new_site_location + '" class=link_style >Operation Hours</a>'
	}

	new_site_location = '/on_patient_history' + document.location.search
	if(type == 'on_patient_history'){
		content += '<a href="' + new_site_location + '" class=link_style_bold >Patient History</a>'
	}else{
		content += '<a href="' + new_site_location + '" class=link_style >Patient History</a>'
	}

	document.getElementById('base_link_id').innerHTML = content
}

function loop(){

	image_div = document.getElementById('base_image_id')
	image_style = image_div.currentStyle || window.getComputedStyle(image_div)
	margin = parseFloat(image_style.marginTop.replace('px',''))
	image_div.style.marginTop = (margin - 2) + 'px'

	if((margin-1) < 0){
		image_div.style.marginTop = '0px'
		return
	}


	image_div = document.getElementById('base_link_id')
	image_style = image_div.currentStyle || window.getComputedStyle(image_div)
	margin = parseFloat(image_style.marginTop.replace('px',''))
	image_div.style.marginTop = (margin - 1) + 'px'

    setTimeout(loop, 1000 * loop_time);
}


